//
//  BiggerTableViewCell.m
//  一点互助
//
//  Created by mac on 16/9/5.
//  Copyright © 2016年 zhangboqiu. All rights reserved.
//

#import "BiggerTableViewCell.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import "URLDefine.h"

@implementation BiggerTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
}
-(void)setModel:(WishesModel *)model{
    _model = model;
    NSURL *picURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@",kGetPicURL,model.avatar]];
    [self.avatarImage sd_setImageWithURL:picURL placeholderImage:[UIImage imageNamed:@"好友-头像9"]];
    self.userNiceName.text = model.userNiceName;
    self.title.text = model.title;
    NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Asia/Shanghai"];
    [formatter setTimeZone:timeZone];
    NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:[model.wishAddTime integerValue]];
    
    NSLog(@"%@",confromTimesp);
    NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
    NSLog(@"confromTimespStr =  %@",confromTimespStr);
    self.addTime.text = confromTimespStr;
    PLLOG(@"%@",confromTimespStr);
    //    PLLOG(@"%@",model.wishAddTime);
    self.wishRewardNum.text = [NSString stringWithFormat:@"打赏人数：%ld",(long)model.wishRewardNum];
    self.wishRewardPrice.text = [NSString stringWithFormat:@"已打赏¥：%ld",(long)model.wishRewardPrice];
    self.wishPrice.text = [NSString stringWithFormat:@"求打赏¥：%ld",(long)model.price];
    self.anotherRewardNumLabel.text = [NSString stringWithFormat:@"%ld",(long)model.wishRewardNum];
    if (model.wishRewardPrice == 0 & model.price == 0) {
        self.wishHot.progress = 0;
    }else if(model.price == 0 && model.wishRewardPrice != 0){
        self.wishHot.progress = 1;
    }else{
        self.wishHot.progress = model.wishRewardPrice/model.price;
    }
    if (model.price == 0) {
        self.hotRate.text = [NSString stringWithFormat:@"0%%"];
    }else{
        self.hotRate.text = [NSString stringWithFormat:@"%.0f%%",model.wishRewardPrice/model.price];
    }
    
}
-(void)layoutSubviews{
    [super layoutSubviews];
    self.avatarImage.layer.cornerRadius = self.avatarImage.bounds.size.height/2;
    self.avatarImage.layer.masksToBounds = YES;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}
@end
